package com.baizhi.service.impl;

import com.baizhi.config.log.LogAnnotation;
import com.baizhi.entity.CmfzAudio;
import com.baizhi.entity.R;
import com.baizhi.mapper.AudioMapper;
import com.baizhi.service.AudioService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Slf4j
@Service
public class AudioServiceImpl implements AudioService {
    @Autowired
    private AudioMapper audioMapper;
    @Transactional
    @LogAnnotation(content = "app查询专辑audio",type = "select")
    public R selectAudio(Integer id) {
        List<CmfzAudio> audios = null;
        try{
            QueryWrapper<CmfzAudio> wrapper = new QueryWrapper<CmfzAudio>().eq("album_id", id);
            List<CmfzAudio> cmfzAudios = audioMapper.selectList(wrapper);
            return R.ok().put("data",cmfzAudios);
        }catch(Exception e){
            return R.error(1004,"查询专辑audio失败");
        }
    }
}
